/**
 * This program is free software but WITHOUT ANY WARRANTY OR CONDITIONS OF ANY KIND.
 *
 * Copyright (C) 2008 www.pretty-tools.com
 */

var wsshSlideShowHelper = {};

wsshSlideShowHelper.isBounded = function (realWidth, realHeight, boundWidth, boundHeight)
{
    return (realWidth <= boundWidth && realHeight <= boundHeight);
}

wsshSlideShowHelper.isScreenBounded = function (realWidth, realHeight)
{
    return this.isBounded(realWidth, realHeight, screen.width, screen.height);
}

wsshSlideShowHelper.getBoundedSize = function (realWidth, realHeight, boundWidth, boundHeight)
{
    if (realWidth <= boundWidth && realHeight <= boundHeight)
        return { width : realWidth, height : realHeight };

    return (realWidth > realHeight)
            ? { width : boundWidth, height : Math.floor(boundWidth * realHeight / realWidth) }
            : { width : Math.floor(boundHeight * realWidth / realHeight), height : boundHeight };
}

wsshSlideShowHelper.getScreenBoundedSize = function (realWidth, realHeight)
{
    return this.getBoundedSize(realWidth, realHeight, screen.width, screen.height);
}

wsshSlideShowHelper.getZoomedSize = function (realWidth, realHeight, boundWidth, boundHeight)
{
    if (realWidth >= boundWidth && realHeight >= boundHeight)
        return { width : realWidth, height : realHeight };

    return (realWidth > realHeight)
            ? { width : boundWidth, height : Math.floor(boundWidth * realHeight / realWidth) }
            : { width : Math.floor(boundHeight * realWidth / realHeight), height : boundHeight };
}

wsshSlideShowHelper.getScreenZoomedSize = function (realWidth, realHeight)
{
    return this.getZoomedSize(realWidth, realHeight, screen.width, screen.height);
}
